/*
Copyright 2022.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import (
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type PushType struct {
	Url       string         `json:"url,omitempty"`
	Auth      AuthType       `json:"auth,omitempty"`
	Forward   string         `json:"forward,omitempty"`
	Gopcache  string         `json:"gopcache,omitempty"`
	ToHttpflv string         `json:"to_httpflv,omitempty"`
	ToHls     string         `json:"to_hls,omitempty"`
	Transcode []TranscodeSub `json:"transcode,omitempty"`
	Process   ProcessType    `json:"process,omitempty"`
}
type PullType struct {
	Url         string        `json:"url,omitempty"`
	Auth        AuthType      `json:"auth,omitempty"`
	Credicard   CredicardType `json:"credicard,omitempty"`
	Forward     string        `json:"forward,omitempty"`
	Gopcache    string        `json:"gopcache,omitempty"`
	EnableHttp  bool          `json:"enableHttp,omitempty"`
	EnableHttps bool          `json:"enableHttps,omitempty"`
	HttpPort    int           `json:"httpPort,omitempty"`
	HttpsPort   int           `json:"httpsPort,omitempty"`
}
type CredicardType struct {
	CertName []string `json:"certName,omitempty"`
	CertPath string   `json:"certPath,omitempty"`
	CertGit  string   `json:"certGit,omitempty"`
}
type AuthType struct {
	AuthEnable   bool   `json:"authEnable,omitempty"`
	PrimaryKey   string `json:"primaryKey,omitempty"`
	SecondaryKey string `json:"secondaryKey,omitempty"`
	Duration     string `json:"duration,omitempty"`
}
type TranscodeSub struct {
	Template string `json:"template,omitempty"`
	ToUrl    string `json:"to_url,omitempty"`
}
type ProcessType struct {
	Dvr DvrType `json:"dvr,omitempty"`
}
type DvrType struct {
	Mp4       string `json:"mp4,omitempty"`
	Hls       string `json:"hls,omitempty"`
	Path      string `json:"path,omitempty"`
	Lifecycle string `json:"lifecycle,omitempty"`
}

// EDIT THIS FILE!  THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required.  Any new fields you add must have json tags for the fields to be serialized.

// PushPullSpec defines the desired state of PushPull
type PushPullSpec struct {
	// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
	// Important: Run "make" to regenerate code after modifying this file

	// Foo is an example field of PushPull. Edit pushpull_types.go to remove/update
	Cpid string   `json:"cpid,omitempty"`
	Push PushType `json:"push,omitempty"`
	Pull PullType `json:"pull,omitempty"`
}

// PushPullStatus defines the observed state of PushPull
type PushPullStatus struct {
	// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
	// Important: Run "make" to regenerate code after modifying this file
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// PushPull is the Schema for the pushpulls API
// +genclient
type PushPull struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   PushPullSpec   `json:"spec,omitempty"`
	Status PushPullStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// PushPullList contains a list of PushPull
type PushPullList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []PushPull `json:"items"`
}

func init() {
	SchemeBuilder.Register(&PushPull{}, &PushPullList{})
}
